/* Author: 

*/
var THEME_URL = THEME_URL || '';
var box = {left: 0, top: 0, width: 0};var total = 0;
function resizeWindow() {
	var $ = jQuery;
	var BodyWidth = $('body').width();
	BodyWidth = BodyWidth < 1024 ? 1024 : BodyWidth;
	box = $('#container > div.box-w').offset();
	box.right = box.left + $('#container > div.box-w').width();
	box.width = box.right - box.left;
	$('#links').css('left', ''+(box.right-183.5)+'px');
	
	$('.left0px').css('left', '-'+(box.left)+'px');
	
	$('#container header > section > aside.client > div.data > h1').each(function(){
		//var r = intval($(this).css('right'), 10);
		var w = 339 + box.left;
		$(this).width(w);
	});
	$('.right0px').each(function(){
		var l = intval($(this).css('left'), 10);
		var w = (box.width - l) + (BodyWidth - box.right);
		$(this).width(w);
	});
	
	$('.center').each(function(){
		var left = ( $(this).parent().width() - $(this).width() )/2;
		$(this).css('left', ''+(left)+'px');
	});
	//$('#container header > section > div.client >h1:first-child').css('left', ''+(box.left+32.5)+'px');
	
	$('*.full').width(BodyWidth);
	
	$('*.full').each(function(){
		if( $(this).css('position') == 'absolute' ) {
			$(this).css('left', '-'+box.left+'px');
		}
	});
	
	var slider = $('aside#slide > .jSlider');
	var width = slider.width();
	slider.children('div.full').each(function(){
		$(this).width(width);
	});
	slider.carouFredSel({
				pagination : $('aside#slide > .pagination'),
				//auto: 10000,
				scroll: {
					//duration: 100,
					pauseOnHover: false,
					onPausePause: function(tt0, perc, dur1) {
						if(total < 5) console.debug('onPausePause('+tt0+', '+perc+', '+(dur1||'')+')'); total++;
						return true;
					},
					onPauseStart: function(tt0, perc, dur1) {
						if(total < 5) console.debug('onPauseStart('+tt0+', '+perc+', '+(dur1||'')+')'); 
						return true;
					},
					onPauseEnd: function(tt0, perc, dur1) {
						if(total < 5) console.debug('onPauseEnd('+tt0+', '+perc+', '+(dur1||'')+')'); 
						return true;
					},
					onBefore: function(tt0, c_old, c_new, w_siz, a_dur) {
						if(total < 5) console.debug('onBefore('+tt0+', '+c_old+', '+', '+c_new+', '+', '+w_siz+', '+(a_dur)+')'); 
						return true;
					},
					onAfter: function(tt0, c_old, c_new, w_siz) {
						if(total < 5) console.debug('onAfter('+tt0+', '+c_old+', '+', '+c_new+', '+', '+w_siz+')'); 
						return true;
					},
					onEnd: function(tt0) {
						if(total < 5) console.debug('onEnd('+tt0+')'); 
						return true;
					},
					conditions: function(tt0) {
						if(total < 5) console.debug('conditions('+tt0+')'); 
						return true;
					}
				}
			});
	var height = $('aside#slide').height();
	slider.height(height).parent().height(height);
	$('#container header > section > aside#slide  div.pagination > a:first-child').addClass('first');
	return;
}
function pauseSlide(pause, next) {
	if(pause)
		jQuery('aside#slide .jSlider').trigger('pause');
	else {
		if(next)
			jQuery('aside#slide .jSlider').trigger('play', 'next');
		else
			jQuery('aside#slide .jSlider').trigger('play', 'prev');
	}
	return;
}
function nextSlide(d) {
	if(d)
		jQuery('aside#slide .jSlider').trigger('next');
	else
		jQuery('aside#slide .jSlider').trigger('prev');
	pauseSlide(1);
}
jQuery(document).ready( function() {
	var $ = jQuery;
	if(window.location.search.match(/debug=[1-9]/i)) {
		var slide = (/debug=([1-9]+)/i).exec(window.location.search);
		$('body').addClass('debug-'+slide[1]);
	}
	$(window).resize(function() {
		setTimeout('resizeWindow()', 10);
	});
	resizeWindow();
	return;
});




